package
{
    import flash.geom.Vector3D;

	import away3d.controllers.HoverController;
    import away3d.core.pick.PickingColliderType;
    import away3d.entities.Mesh;
    import away3d.events.MouseEvent3D;
    import away3d.lights.DirectionalLight;
    import away3d.materials.TextureMultiPassMaterial;
    import away3d.materials.lightpickers.StaticLightPicker;
    import away3d.primitives.PlaneGeometry;
    import away3d.utils.Cast;

    import brickred.containers.Scene;
    import brickred.core.Director;
    import brickred.core.Logger;

    public class Scene1 extends Scene
    {
		//plane textures
		[Embed(source="/assets/floor_diffuse.jpg")]
		public static var FloorDiffuse:Class;
		[Embed(source="/assets/floor_specular.jpg")]
		public static var FloorSpecular:Class;
		[Embed(source="/assets/floor_normal.jpg")]
		public static var FloorNormals:Class;

        private var light_:DirectionalLight;
		private var light_picker_:StaticLightPicker;
        private var plane_material_:TextureMultiPassMaterial;
		private var plane_:Mesh;

        public function Scene1()
        {
            scene2d_.addChild(new SceneNaviBar());

            light_ = new DirectionalLight(0, -1, 0);
            light_.castsShadows = false;
			light_.color = 0xeedddd;
			light_.diffuse = .5;
			light_.ambient = .5;
			light_.specular = 0;
			light_.ambientColor = 0x808090;
            scene3d_.addChild(light_);

            light_picker_ = new StaticLightPicker([light_]);

			plane_material_ = new TextureMultiPassMaterial(Cast.bitmapTexture(FloorDiffuse));
			plane_material_.specularMap = Cast.bitmapTexture(FloorSpecular);
			plane_material_.normalMap = Cast.bitmapTexture(FloorNormals);
			plane_material_.lightPicker = light_picker_;
			plane_material_.repeat = true;
			plane_material_.mipmap = false;
			plane_material_.specular = 10;

			plane_ = new Mesh(new PlaneGeometry(1000, 1000), plane_material_);
			plane_.geometry.scaleUV(2, 2);
			plane_.y = -20;
            plane_.addEventListener(MouseEvent3D.CLICK, onMouseClick);
            plane_.mouseEnabled = true;
            scene3d_.addChild(plane_);

            camera_.position = new Vector3D(500, 500, 500);
            camera_.lookAt(new Vector3D());
        }

        private function onMouseClick(event:MouseEvent3D):void
        {
            Logger.log("Mouse clicked");
        }
    }
}
